package cn.tedu.mall.book.controller;

import cn.tedu.mall.book.pojo.dto.ConsigneeDTO;
import cn.tedu.mall.book.pojo.vo.ConsigneeVO;
import cn.tedu.mall.book.service.IConsigneeService;
import cn.tedu.mall.book.web.JsonResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zxjun
 * @date 2022/6/30 19:31
 */
@RestController
@Api(tags = "收货人管理")
@RequestMapping("/consignee")
public class ConsigneeController {
    @Autowired
    private IConsigneeService consigneeService;
    @PostMapping("/add")
    public JsonResult addNew(@RequestBody ConsigneeDTO consigneeDTO){
        consigneeService.addNew(consigneeDTO);
        return JsonResult.ok("新增收货人信息成功");
    }
    @PostMapping("/update")
    public JsonResult updateById(@RequestBody ConsigneeDTO consigneeDTO){
        consigneeService.updateById(consigneeDTO);
        return JsonResult.ok(

        );
    }
    @GetMapping("/display/{id}")
    public JsonResult setDisplay(@PathVariable Integer id){
        consigneeService.updateIsDisplayById(id);
        return JsonResult.ok("改为显示成功");
    }

    @GetMapping("/delete/{id}")
    public JsonResult deleteById(@PathVariable Integer id){
        consigneeService.deleteById(id);
        return JsonResult.ok("删除收货人信息成功");
    }

    @GetMapping("/get/{id}")
    public JsonResult<ConsigneeVO> getById(@PathVariable Integer id){
        return JsonResult.ok(consigneeService.getById(id));
    }
    @GetMapping("/getDisplay")
    public JsonResult getDisplay(){
        return JsonResult.ok(consigneeService.getDisplay());
    }

    @GetMapping("/list")
    public JsonResult getList(){
        return JsonResult.ok(consigneeService.getList());
    }
}
